import { Component, OnInit } from '@angular/core';
import {BaseService} from "../../../shared/service/base.service";
import {ActivatedRoute, NavigationEnd, Router} from "@angular/router";
import {filter} from "rxjs/operators";
import {Consts} from "../../../config/consts";
import {ApiUrl} from "../../../config/api-url";
import {UserInfoModel} from '../../../models/user-info.model';
import {RoleIdEnum} from '../../../enums/role-id.enum';

@Component({
  selector: 'app-first',
  templateUrl: './first.component.html',
  styleUrls: ['./first.component.less']
})
export class FirstComponent implements OnInit {

  dayCount: any;
  yesterdayCount: any;
  // 用户信息
  userInfo: UserInfoModel;
  roleIdEnum = {
    SUPER_ADMINISTRATOR: RoleIdEnum.SUPER_ADMINISTRATOR,
    AGENT: RoleIdEnum.AGENT,
    MERCHANT: RoleIdEnum.MERCHANT,
  };
  constructor(private baseService: BaseService, private activatedRoute: ActivatedRoute, private router: Router) {

  }

  ngOnInit(): void {
    this.userInfo = JSON.parse(sessionStorage.getItem(Consts.USER_INFO));
    this.findCountDay();
    this.findCountMonth();
  }

  findCountDay(){
    this.baseService.get(ApiUrl.HomeUrl+"/findCountDay").subscribe(res => {
      this.dayCount = res.data;
    })
  }
  findCountMonth(){
    this.baseService.get(ApiUrl.HomeUrl+"/findCountYesterday").subscribe(res => {
      if(res.status == 0){
        this.yesterdayCount = res.data;
      }else{
        this.baseService.layer.messageError(res.msg)
      }
    })
  }
}
